<!-- 拒保弹框 -->
<template>
    <el-dialog v-model="showDialog" title="驳回" width="500">
        <el-input v-model="reason" placeholder="请输入驳回理由" show-word-limit type="textarea" />
        <div class="flexcenterbox" style="margin-top: 40px">
            <el-button class="my_cancelbtn" @click="onCancel">取消</el-button>
            <el-button class="my_btn" @click="onConfirm">确定</el-button>
        </div>
    </el-dialog>
</template>
<script lang="ts" setup>
import { ref, watch } from 'vue'
import {
    ElMessage,
} from 'element-plus'
import { rejectAgree } from '@/api/tools/accountLogout'

const props = defineProps({
    show: {
        type: Boolean,
        default: false
    },
    recordId: {
        type: Number,
        required: true
    }
})

const emits = defineEmits(['update:show', 'success'])

const showDialog = ref(false)

const reason = ref('')

const onCancel = () => {
    showDialog.value = false
}

const onConfirm = async () => {
    if (reason.value === '') {
        ElMessage({ message: '请输入驳回理由', type: 'warning' })
        return
    }
    await rejectAgree({
        id: props.recordId,
        rejectRemark: reason.value
    })
    showDialog.value = false
    emits('success')
}

watch(() => props.show, (newval) => {
    showDialog.value = newval
})

watch(showDialog, (newval) => {
    emits('update:show', newval)
})
</script>
<style lang="scss" scoped></style>